<template>
  <div class="building-management">
    <el-card>
      <h2>楼宇管理</h2>
      <el-table :data="buildings" style="width: 100%" border>
        <el-table-column prop="id" label="楼宇ID" width="100" />
        <el-table-column prop="code" label="楼宇编号" />
        <el-table-column prop="name" label="楼宇名称" />
        <el-table-column prop="communityId" label="所属小区ID" />
        <el-table-column prop="layers" label="总层数" />
        <el-table-column prop="structure" label="结构" />
        <el-table-column prop="longitude" label="经度" />
        <el-table-column prop="latitude" label="纬度" />
        <el-table-column prop="remark" label="备注" />
        <el-table-column prop="createBy" label="创建人" />
        <el-table-column prop="createTime" label="创建时间" />
      </el-table>
    </el-card>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { ElMessage } from 'element-plus'
import request from '../utils/request'

const buildings = ref([])

const fetchBuildings = async () => {
  try {
    const res = await request.get('/infrastructure-server/building/all')
    buildings.value = res.data
  } catch (e) {
    ElMessage.error('获取楼宇列表失败')
  }
}

onMounted(() => {
  fetchBuildings()
})
</script>

<style scoped>
.building-management {
  padding: 20px;
}
</style> 